<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich" 
	template="layout/template.xhtml">

	<ui:define name="body">

		<h:form id="ventaSearch" styleClass="edit">

			<rich:simpleTogglePanel label="Filtros de Busqueda" switchType="ajax">

				<s:decorate template="layout/display.xhtml">
					<ui:define name="label">Fecha de venta</ui:define>
					<rich:calendar id="fecha" value="#{ventaList.venta.fecha}"
						enableManualInput="true" datePattern="dd/MM/yyyy">
					</rich:calendar>
					<ui:param name="fechaDeVenta" value="#{ventaList.venta.fecha}" />
				</s:decorate>

			</rich:simpleTogglePanel>

			<div class="actionButtons"><h:commandButton id="search"
				value="Buscar" action="/VentaList.xhtml" /> <s:button id="reset"
				value="Limpiar Busqueda" includePageParams="false" /></div>

		</h:form>

		<rich:panel>
			<f:facet name="header">Resultados </f:facet>
			<div class="results" id="ventaList"><h:outputText
				value="No hay ventas que coincidan con la busqueda"
				rendered="#{empty ventaList.resultList}" /> <rich:dataTable
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
				id="ventaList" var="_venta" value="#{ventaList.resultList}"
				rendered="#{not empty ventaList.resultList}">
				<h:column>
					<f:facet name="header">
						<ui:include src="layout/sort.xhtml">
							<ui:param name="entityList" value="#{ventaList}" />
							<ui:param name="propertyLabel" value="Fecha" />
							<ui:param name="propertyPath" value="venta.fecha" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_venta.fecha}">
						<s:convertDateTime type="both" dateStyle="short"
							pattern="dd/MM/yyyy" />
					</h:outputText>
				</h:column>

				<h:column>
					<f:facet name="header">
						<h:outputText value="Codigo" />
					</f:facet>
					<h:outputText value="#{relacionCompraCodigoUnicoHome.obtenerCodigoUnicoParaCompra(_venta.compra)}" />
				</h:column>

				<h:column>
					<f:facet name="header">
						<ui:include src="layout/sort.xhtml">
							<ui:param name="entityList" value="#{ventaList}" />
							<ui:param name="propertyLabel" value="Descuento" />
							<ui:param name="propertyPath" value="venta.descuento" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_venta.descuento} %" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<ui:include src="layout/sort.xhtml">
							<ui:param name="entityList" value="#{ventaList}" />
							<ui:param name="propertyLabel"
								value="Precio de venta establecido" />
							<ui:param name="propertyPath" value="venta.precioDeVenta" />
						</ui:include>
					</f:facet>
					<h:outputText value="$ #{_venta.compra.precioDeVenta}" />
				</h:column>

				<h:column>
					<f:facet name="header">
						<ui:include src="layout/sort.xhtml">
							<ui:param name="entityList" value="#{ventaList}" />
							<ui:param name="propertyLabel" value="Precio al que se vendio" />
							<ui:param name="propertyPath"
								value="venta.precioDeVentaModificado" />
						</ui:include>
					</f:facet>
					<h:outputText value="$ #{_venta.precioDeVenta}" />
				</h:column>

				<h:column>
					<f:facet name="header">
						<ui:include src="layout/sort.xhtml">
							<ui:param name="entityList" value="#{ventaList}" />
							<ui:param name="propertyLabel" value="Tipo de pago" />
							<ui:param name="propertyPath" value="venta.tipoPago.idTipoPago" />
						</ui:include>
					</f:facet>
					<h:outputText
						value="#{_venta.tipoPago.sigla} - #{_venta.tipoPago.descripcion}" />
				</h:column>
				<rich:column styleClass="action">
					<f:facet name="header">Accion</f:facet>
					<s:link view="/#{empty from ? 'Venta' : from}.xhtml"
						value="#{empty from ? 'Ver' : 'Seleccionar'}"
						propagation="#{empty from ? 'none' : 'default'}" id="ventaViewId">
						<f:param name="ventaIdVenta" value="#{_venta.idVenta}" />
					</s:link>
				</rich:column>
			</rich:dataTable></div>
		</rich:panel>

		<div class="tableControl"><s:link view="/VentaList.xhtml"
			rendered="#{ventaList.previousExists}"
			value="#{messages.left}#{messages.left} Primera Pagina"
			id="firstPage">
			<f:param name="firstResult" value="0" />
		</s:link> <s:link view="/VentaList.xhtml"
			rendered="#{ventaList.previousExists}"
			value="#{messages.left} Pagina Anterior" id="previousPage">
			<f:param name="firstResult" value="#{ventaList.previousFirstResult}" />
		</s:link> <s:link view="/VentaList.xhtml" rendered="#{ventaList.nextExists}"
			value="Pagina siguiente #{messages.right}" id="nextPage">
			<f:param name="firstResult" value="#{ventaList.nextFirstResult}" />
		</s:link> <s:link view="/VentaList.xhtml" rendered="#{ventaList.nextExists}"
			value="Ultima pagina #{messages.right}#{messages.right}"
			id="lastPage">
			<f:param name="firstResult" value="#{ventaList.lastFirstResult}" />
		</s:link></div>

		<s:div styleClass="actionButtons" rendered="#{empty from}">
			<s:button view="/VentaEdit.xhtml" id="create" propagation="none"
				value="Cargar venta" rendered="false">
				<f:param name="ventaIdVenta" />
			</s:button>
		</s:div>

	</ui:define>

</ui:composition>
